POV-Ray : Newsgroups : povray.advanced-users : Povray Parser for Moray : Re: Povray Parser for Moray Server Time
29 Jul 2024 16:24:16 EDT (-0400)
  Re: Povray Parser for Moray  
From: Lutz Kretzschmar
Date: 17 Oct 2001 19:22:50
Message: <lf3sstsk4qui3ombgr4dat4se1d51lh449@4ax.com>
Hi Keith Hull, you recently wrote in povray.advanced-users:

> I can't change the base/cap vectors only the scale/rotate/translate vectors.
> Does anybody have any ideas? 
I have an idea :-)

Think of a vector from the middle of the base to the middle of the cap
(i.e. connecting the two given endpoints).
Transform it so that the base is in the origin (basically subtract P2
from P1).
Now figure out how to rotate it so that it's aligned along Z.
You now need to set Moray's *local* coordinate system to the
determined values. This is important, so that you can still do the
later transformations. 

In your example, it works out to setting the local coordinates to
roughly this (determined by trial and error right now :-) :
Scale     : 1, 1, 9.1  (the Z component is the length of the vector)
Rotate    : 0, -71, 35  (exercise for the reader :-)
Translate : -2, -1, 1  (this is the position of the base point)

What this does it to create a cone that has it's origin where POV-Ray
expects it, since later scales, rotations occur around the origin, not
around the base point.

The other scale, rotate, translates are derived like for every other
normal object. The best thing to do is to accumulate the
transformations in a matrix and then decompose the matrix back into
the three basic vectors. There are cases where this breaks down, you
can see the effects in IK sometimes, but generally it should work. As
Ron and Peter mentioned, if the transformations result in shearing
(rotate followed by scaling), then this cannot be handled in Moray,
but that applies to every object and has nothing to do with this
specific cone issue.

I could expose Moray's decomposition function in the plugin interface,
if you want to save yourself the coding. It's going to change for
POV-Ray 3.5 anyway :-)

Good luck.

- Lutz
  email : lut### [at] stmuccom
  Web   : http://www.stmuc.com/moray


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.